package org.linlinjava.litemall.db.util;

import java.util.Arrays;

public enum StatisticsFuncEnum {

    /**
     *
     */
    DATE("date", "DATE"),
    WEEK("week", "WEEK"),
    MONTH("month", "MONTH"),
    QUARTER("quarter", "QUARTER"),
    YEAR("year", "YEAR"),;

    private String orderBy;

    private String func;

    StatisticsFuncEnum(String orderBy, String func) {
        this.orderBy = orderBy;
        this.func = func;
    }

    public static StatisticsFuncEnum fromOrderBy(String orderBy) {
        return Arrays.stream(StatisticsFuncEnum.values())
                .filter(e -> e.getOrderBy().equals(orderBy))
                .findFirst()
                .orElse(null);
    }

    public String getOrderBy() {
        return this.orderBy;
    }

    public String getFunc() {
        return this.func;
    }
}
